import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2022/1/25
 * Time: 14:14
 * Description:
 */
public class TestDemo {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);//资源
        Random random = new Random(4789);
        int randNum = random.nextInt(100) + 1;//[0-100)->[1,100]
        while (true) {
            System.out.println("你要猜的数字：");
            int num = scanner.nextInt();
            if(randNum < num) {
                System.out.println("你猜大了！");
            }else if(randNum > num) {
                System.out.println("你猜小了！");
            }else {
                System.out.println("你猜对了！");
                break;
            }
        }
    }

    public static void main20(String[] args) {
        Scanner scanner = new Scanner(System.in);//资源

        System.out.println("请输入你的年龄：");
        int age = scanner.nextInt();
        System.out.println(age);

        System.out.println("请输入你的姓名：");
        String name = scanner.nextLine();
        System.out.println("name:"+name);

        System.out.println("输入你的工资：");
        float f = scanner.nextFloat();
        System.out.println(f);

        scanner.close();//记住关闭
    }

    public static void main19(String[] args) {
        int a = 0;
        do {
            System.out.println("haha");
        }while (a > 0);
    }


    /**
     * 求阶乘的和，用for
     * @param args
     */
    public static void main18(String[] args) {
        int n = 5;
        int sum = 0;
        for (int j = 1; j <= n ; j++) {
            int ret = 1;
            for (int i = 1; i <= j; i++) {
                ret *= i;
            }
            sum += ret;
        }
        System.out.println(sum);
    }

    public static void main17(String[] args) {
        int sum = 0;
        int i = 1;
        for ( ; ;i++) {
            //sum += i;
            System.out.println("fa");
        }
        //System.out.println(sum);
    }


    public static void main16(String[] args) {
        int sum = 0;
        for (int i = 1; i <= 10; i++) {
            sum += i;
        }
        System.out.println(sum);

        int sum2 = 0;
        int j = 1;
        while (j <= 10) {
            sum2+=j;
            j++;
        }
        System.out.println(sum2);
    }

    /**
     * 找到1-100之间  既能被3整除，也能被5整除的所有数字
     *
     *
     * @param args
     */
    public static void main15(String[] args) {
        int i = 1;
        while (i <= 100) {
            if(i % 15 != 0) {
                i++;
                continue;
            }
            System.out.println(i);
            i++;
        }
    }

    /**
     * 找到所有3的倍数
     * @param args
     */
    public static void main14(String[] args) {
        int i = 1;
        while (i <= 10) {
            if(i % 3 != 0) {
                i++;
               continue;
            }
            System.out.println(i);
            i++;
        }
    }

    public static void main13(String[] args) {
        int a = 1;
        while (a < 10) {
            if(a == 2) {
                a++;
                continue;//死循环
                //System.out.println("haha");
            }
            System.out.println(a);
            a++;
        }
    }


    public static void main12(String[] args) {
        int i = 100;
        while (i <= 200) {
            if(i % 3 == 0) {
                System.out.println(i);
                break;
            }
            i++;
        }
    }


    public static void main11(String[] args) {
        int a = 1;
        while (a < 10) {
            if(a == 5) {
                break;
            }
            System.out.println(a);
            a++;
        }
    }

    public static void main10(String[] args) {
        int a = 10;
        while (a < 100){
            System.out.println(a);
            a++;
        }
    }

    /**
     * 求n的阶乘的和
     * @param args
     */
    public static void main9(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();//5
        int j = 1;
        int sum = 0;
        while (j <= n) {
            int ret = 1;
            int i = 1;
            while (i <= j) {
                ret *= i;
                i++;
            }
            sum += ret;
            j++;
        }
        System.out.println(sum);
    }


    public static void main8(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int ret = 1;
        int i = 1;
        while (i <= n) {
            ret *= i;
            i++;
        }
        System.out.println(ret);
    }

    public static void main7(String[] args) {
        int num = 1;
        int ret = 0;
        while (num <= 10) {
            ret+=num;
            num++;
        }
        System.out.println(ret);

/*
        while (true) {
            System.out.println("fsafa");
        }*/
    }

    public static void main6(String[] args) {
        int a = 10;
        switch (a) {
            case 1:
                System.out.println("2");
                break;
            case 2:
                System.out.println("1");
                break;
            default:
                System.out.println("输入有误");
                break;
        }
    }


    public static void main5(String[] args) {
        String a = "hello";
        switch (a) {
            case "hello":
                System.out.println("2");
                break;
            case "ew":
                System.out.println("1");
                break;
            default:
                System.out.println("输入有误");
                break;
        }
    }

    public static void main4(String[] args) {
        int x = 20;
        int y = 10;
        if (x == 10) {
            if (y == 10) {
                System.out.println("aaa");
            }else {
                System.out.println("bbb");
            }
        }
    }

    public static void main3(String[] args) {
        //随着自己写代码 ，代码的提示是你要的  你就可以直接回车
        Scanner scanner = new Scanner(System.in);
        //ctr+D=> 要学会这样写  因为以后的OJ题 都是这样的
        while (scanner.hasNextInt()) {
            int year = scanner.nextInt();
            if(year % 100 == 0) {
                if(year % 400 == 0) {
                    System.out.println(year+" is leapYear!");
                }else {
                    System.out.println(year+" is not leapYear!");
                }
            }else {
                if(year % 4 == 0) {
                    System.out.println(year+" is leapYear!");
                }else {
                    System.out.println(year+" is not leapYear!");
                }
            }
        }
    }

    public static void main2(String[] args) {
        //随着自己写代码 ，代码的提示是你要的  你就可以直接回车
        Scanner scanner = new Scanner(System.in);
        //ctr+D=> 要学会这样写  因为以后的OJ题 都是这样的
        while (scanner.hasNextInt()) {
            int num = scanner.nextInt();
            if(num % 2 == 0) {
                System.out.println("偶数");
            }else {
                System.out.println("奇数");
            }
        }
    }


    public static void main1(String[] args) {
        System.out.println("aaa");
        System.out.println("ccc");
        System.out.println("bbb");
        int a = 1;
        if(a < 10) {
            System.out.println("fsafdsaa");
        }
    }
}
